package com.eling.elcms.travel.service.impl;

import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.travel.dao.ISignUpRefundDao;
import com.eling.elcms.travel.model.SignUpRefund;
import com.eling.elcms.travel.model.view.SignUpRefundView;
import com.eling.elcms.travel.service.ISignUpRefundManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class SignUpRefundManagerImpl extends GenericManagerImpl<SignUpRefund, Long> implements ISignUpRefundManager {
	
	ISignUpRefundDao signUpRefundDao;

	@Autowired
	public SignUpRefundManagerImpl(ISignUpRefundDao dao) {
		this.dao = dao;
		this.signUpRefundDao = dao;
	}

	public SignUpRefundView saveAll(SignUpRefundView data){
		
		List<SignUpRefund> list = data.getList();
		List<SignUpRefund> rlist = new ArrayList<SignUpRefund>(); 
		for(SignUpRefund signUpRefund:list){
			SignUpRefund t = dao.get(signUpRefund.getPkSignUpRefund());
			t.setRefund(signUpRefund.getRefund());
			t.setOperator(signUpRefund.getOperator());
			t.setRefundDate(new Date());
			rlist.add(t);
		}
		dao.save(rlist);
		return new SignUpRefundView();
	}
	
}
